/*
 * @Author: Allan
 * @Date: 2022-05-20 17:53:35
 * @LastEditors: Allan
 * @LastEditTime: 2022-05-20 17:53:41
 * @FilePath: \studygo\并发\select.go
 * @Description:
 *
 * Copyright (c) 2022 by Allan / ganger@whut.edu.cn, All Rights Reserved.
 */
package main

import "fmt"

func main() {
	ch := make(chan int, 1)
	// 会输出1、3、5、7、9
	for i := 1; i <= 10; i++ {
		select {
		case x := <-ch:
			// i = 2 4 6 8 10时执行这个case
			fmt.Println(x)
		case ch <- i:
			// i = 1 3 5 7 9时执行这个case
		}
	}
}
